import 'package:animated_text_kit/animated_text_kit.dart';
import 'package:flutter/material.dart';

import '../../config/base.dart';
import '../../utils/screenutil/fit.dart';

class TextLoading extends StatelessWidget {
  final String loadingText;
  final double loadUntil;

  /// 文字填充动画
  /// * [loadingText] String|展示的字样|选填|默认：loading
  /// * [loadUntil] double|完成的进度|选填
  TextLoading({this.loadingText = BaseConfig.APPTITLE, this.loadUntil = .8});

  @override
  Widget build(BuildContext context) {
    const double size = 220;
    return Container(
      child: Center(
        child: ClipRRect(
          borderRadius: BorderRadius.circular(size / 2),
          child: Container(
            decoration: BoxDecoration(color: Color.fromRGBO(159, 159, 159, 1)),
            child: TextLiquidFill(
              boxWidth: fit(size),
              boxHeight: fit(size),
              loadUntil: loadUntil,
              text: loadingText,
              waveColor: Colors.blueAccent,
              boxBackgroundColor: Color.fromRGBO(250, 250, 250, 1),
              textStyle: TextStyle(
                fontSize: 40.f,
                fontFamily: 'RubikMonoOne',
                fontStyle: FontStyle.italic,
              ),
            ),
          ),
        ),
      ),
    );
  }
}
